Obsidian Enhancing Export Plugin

une extension1 par Mokeyish

Julien Rabaud

2023-05-12

YAML Pandoc fields

Tous les fichiers quel que soit le format visé

author: "Prénom Nom^[affiliation]"
title: "Titre"
subtitle: "Source^[<url>]"
date: 2023-05-16
lang: fr
# tags: [tag1, tag2]
# url: https://link.org/index.html

à ajouter en fonction du format visé

HTML

PDF

DOCX

Paramètres du Plugin : Extra Pandoc Arguments

HTML

(Plugin) Arguments :

-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/math_block.lua" --standalone -s -o "${outputPath}" -t html

(User) Extra Arguments

--mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js" -C --bibliography="${vaultDir}/DATA/bib/MabibliothèqueSync.json" --csl="${vaultDir}/DATA/CSL/transversalites-Braud.csl" --toc --toc-depth=5 -H "${vaultDir}/DATA/pandoc-add.css" -H "${vaultDir}/DATA/pandoc-js.html" -B "${vaultDir}/DATA/pandoc-logo.html" --reference-links --highlight-style=espresso -F mermaid-filter.cmd --lua-filter="${vaultDir}/DATA/obsidian-callouts.lua"

--lua-filters

Convertir les Callouts (filtre lua)

Below a quick-and-dirty solution which converts Obsidian callout blocks

[!NOTE]- Note Title 

Note content

to Pandoc’s native Divs

::: {.callout data-callout="note" title="Note Title"} 
Note content 
:::

with the following Pandoc command:

pandoc -t markdown --lua-filter obsidian-callouts.lua file.md

Important: Please note, that in order for this simple filter to work properly, callout type and title line should occupy a separate paragraph.

Here the content of the obsidian-callouts.lua file:

local stringify = (require "pandoc.utils").stringify

function BlockQuote (el)
    start = el.content[1]
    if (start.t == "Para" and start.content[1].t == "Str" and
        start.content[1].text:match("^%[!%w+%][-+]?$")) then
        _, _, ctype = start.content[1].text:find("%[!(%w+)%]")
        el.content:remove(1)
        start.content:remove(1)
        div = pandoc.Div(el.content, {class = "callout"})
        div.attributes["data-callout"] = ctype:lower()
        div.attributes["title"] = stringify(start.content):gsub("^ ", "")
        return div
    else
        return el
    end
end

You can modify it to convert callout blocks depending on the output format (HTML, LaTeX, etc.)

.callout {
    color:black;
    margin: 1em 1.4em 2em 2.4em;
    padding: 1em 1em;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    font-family: Arial, Helvetica, sans-serif;
    font-size:0.9em;
    height: 1.2em;
    overflow: hidden;
    transition-duration: 0.8s;
}

.callout:hover {
    height: fit-content;
    transition-duration: 0.6s;
}

.callout::before {
    content: "⌵ " attr(title) " ⌵";
    font-weight: 600;
}

.callout[data-callout="note"] {
    border-left: 4px solid deeppink;
    background-color:lavender;
}

.callout[data-callout="note"]::before {
    color: deeppink;
}

.callout[data-callout="info"] {
    border-left: 4px solid cadetblue;
    background-color:ivory;
}

.callout[data-callout="info"]::before {
    color: cadetblue;
}

.callout[data-callout="example"] {
    border-left: 4px solid peru;
    background-color:gainsboro;
}

.callout[data-callout="example"]::before {
    color: peru;
}

.callout p {
    text-indent: 0em;
    text-align: left;
}

PDF

(Plugin) Arguments :

-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/pdf.lua" --embed-resources --standalone -s -o "${outputPath}" -t pdf

(User) Extra Arguments

--pdf-engine=xelatex -C --bibliography="${vaultDir}/DATA/bib/MabibliothèqueSync.json" --csl="${vaultDir}/DATA/CSL/transversalites-Braud.csl" --toc --toc-depth=5 --reference-links --highlight-style=espresso -F mermaid-filter.cmd --lua-filter obsidian-callouts.lua -V links-as-notes=true

DOCX

(Plugin) Arguments :

-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" -s -o "${outputPath}" -t docx

(User) Extra Arguments

--toc --toc-depth=5 -C --bibliography="${vaultDir}/DATA/bib/MabibliothèqueSync.json" --csl="${vaultDir}/DATA/CSL/transversalites-Braud.csl" -F mermaid-filter.cmd

Extras

Thèmes de coloration syntaxique du code

pandoc --list-highlight-styles
--highlight-style=espresso